package com.example.demo.dao;

import com.example.demo.entity.CircleLike;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 点赞相关的数据库操作类
 */
public interface CircleLikeDao extends JpaRepository<CircleLike,Integer> {
    List<CircleLike> findByUserIdAndCircleId(int userId,int circleId);

    @Query(value = "select nickname  from user where id in   (select userId from circle_like where circleId = ?1 and status=1)",nativeQuery = true)
    List<String> getLikeUsers(int circleId);

    @Query(value = "select count(circleId) from circle_like where userId = ?1 and status=1",nativeQuery = true)
    int getLikeCount(int userId);
}
